package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.MesProdRecord;
import com.ruoyi.order.service.IMesProdRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产记录Controller
 * 
 * @author guoxl
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/order/prodRecord")
public class MesProdRecordController extends BaseController
{
    @Autowired
    private IMesProdRecordService mesProdRecordService;

    /**
     * 查询生产记录列表
     */
    @PreAuthorize("@ss.hasPermi('order:prodRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesProdRecord mesProdRecord)
    {
        startPage();
        List<MesProdRecord> list = mesProdRecordService.selectMesProdRecordList(mesProdRecord);
        return getDataTable(list);
    }

    /**
     * 导出生产记录列表
     */
    @PreAuthorize("@ss.hasPermi('order:prodRecord:export')")
    @Log(title = "生产记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesProdRecord mesProdRecord)
    {
        List<MesProdRecord> list = mesProdRecordService.selectMesProdRecordList(mesProdRecord);
        ExcelUtil<MesProdRecord> util = new ExcelUtil<MesProdRecord>(MesProdRecord.class);
        util.exportExcel(response, list, "生产记录数据");
    }

    /**
     * 获取生产记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:prodRecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(mesProdRecordService.selectMesProdRecordByRecordId(recordId));
    }

    /**
     * 新增生产记录
     */
    @PreAuthorize("@ss.hasPermi('order:prodRecord:add')")
    @Log(title = "生产记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesProdRecord mesProdRecord)
    {
        return toAjax(mesProdRecordService.insertMesProdRecord(mesProdRecord));
    }

    /**
     * 修改生产记录
     */
    @PreAuthorize("@ss.hasPermi('order:prodRecord:edit')")
    @Log(title = "生产记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesProdRecord mesProdRecord)
    {
        return toAjax(mesProdRecordService.updateMesProdRecord(mesProdRecord));
    }

    /**
     * 删除生产记录
     */
    @PreAuthorize("@ss.hasPermi('order:prodRecord:remove')")
    @Log(title = "生产记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(mesProdRecordService.deleteMesProdRecordByRecordIds(recordIds));
    }
}
